/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "i18n_breakIterator_impl.h"
#include <memory>
#include "i18n_hilog.h"

namespace OHOS {
namespace Global {
namespace I18n {
CBreakIterator::CBreakIterator(std::string localeTag)
{
    brkiter_ = std::make_unique<I18nBreakIterator>(localeTag);
    if (brkiter_ == nullptr) {
        HILOG_ERROR_I18N("Create I18nBreakIterator fail");
    }
}

void CBreakIterator::SetLineBreakText(const char* text)
{
    brkiter_->SetText(text);
}

std::string CBreakIterator::GetLineBreakText()
{
    std::string res;
    brkiter_->GetText(res);
    return res;
}

int32_t CBreakIterator::current()
{
    return brkiter_->Current();
}

int32_t CBreakIterator::first()
{
    return brkiter_->First();
}

int32_t CBreakIterator::last()
{
    return brkiter_->Last();
}

int32_t CBreakIterator::next(int32_t number)
{
    return brkiter_->Next(number);
}

int32_t CBreakIterator::previous()
{
    return brkiter_->Previous();
}

int32_t CBreakIterator::following(int32_t offset)
{
    return brkiter_->Following(offset);
}

bool CBreakIterator::IsBoundary(int32_t offset)
{
    return brkiter_->IsBoundary(offset);
}
}  // namespace I18n
}  // namespace Global
}  // namespace OHOS